-
-
Notifications
You must be signed in to change notification settings - Fork 161
London | Nadarajah_Sripathmanathan | book -library | Module-Data-Flows #178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
hi, |
cjyuan
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there are some improvements you can make.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I checked the code in index.html at https://validator.w3.org/, it indicated some errors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In terms of input validation,
- Are all input properly checked?
- Can
.valuebenull? (Do we need to checksomeInputElement.value == null?) - What if a user enters only space characters in the "title" input field?
- What if a users enters
-1or3.1416in the "pages" input field?
With the way the book's title is assigned to an HTML element, a book with a title containing special character sequence such as <i> can possibly ruin the display.
debugging/book-library/script.js
Outdated
| for (let n = rowsNumber - 1; n > 0; n--) { | ||
| table.deleteRow(n); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of deleting the table rows one by one, can you think of a more efficient way to remove all rows (except the <th>...</th>) in the table?
debugging/book-library/script.js
Outdated
| alert(`You've deleted title: ${myLibrary[i].title}`); | ||
| myLibrary.splice(i, 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At the moment when the alert message is displayed, has the book mentioned in the message been deleted yet?
How would you rearrange these statements to make the message truthful?
|
I do not see any changes made to the files. I am removing the "Complete" label for now. |
|
My feedback was not fully responded. |
cjyuan
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes look good.
Would be better if you can make this branch clean so that it only contains the two modified files that belong to the Book Library task.
| if (titleValue.length === 0) { | ||
| alert("Title cannot be just spaces!"); | ||
| return; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check is redundant.
| } | ||
|
|
||
| const pagesNumber = parseInt(pagesValue, 10); | ||
| if (isNaN(pagesNumber) || pagesNumber < 1 || !Number.isInteger(pagesNumber)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You were using parseInt(). Why further check if pagesNumber is integer?
|
|
||
| changeReadButton.addEventListener("click", function () { | ||
| myLibrary[i].read = !myLibrary[i].read; | ||
| changeReadButton.textContent = myLibrary[i].read ? "Yes" : "No"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could also consider calling render() to update the view to avoid maintaining two sets of code to update view.
Learners, PR Template
Self checklist
Changelist
Briefly explain your PR.
Questions
Ask any questions you have for your reviewer.